* Generate Table B.3 (Sensitivity with respect to sample of nominal devaluations)
use "Empirics/AggregateData/Database/output/Database.dta", clear
cd "Empirics/AggregateData/Analysis"
set more off
graph drop _all
local pretrends=0 

*. Where to store results
local outputfolder "output"

*. Set Window length
local windowstart=-4
local windowend=8

*. Minimum # years events need to be apart
local apart=4 // baseline

*. Create variables & Declare panel
qui do "Analysis_dofiles/CreateVars.do" `outputfolder'

*. Identify Large Devaluations
gen largeDevaluationN = 1 if gER<=-0.20 & acceER<=-0.10

* Ensure events are X years apart, where X is given by `apart'
qui do "Analysis_dofiles/Apart.do" `apart' `outputfolder' `windowstart' `windowend' 

* Additional sample adjustments
qui do "Analysis_dofiles/Adjustments.do"

*. Extract list of events in the sample
qui do "Analysis_dofiles/ExtractList.do"

sort id year
*. Create more variables:
qui do "Analysis_dofiles/CreateMoreVars.do"

* Generate Table B.3 and save	
do "Analysis_dofiles/Regressions_Sensitivity.do" `outputfolder' `pretrends'
esttab One Two Three Four Five Six Seven Eight Nine using "../../../Output/TableB3.csv", label keep(deva) b(%9.2f) se stats(r2 N) star(* 0.1 ** 0.05 *** 0.01) replace

cd ../../..
